package com.zgcs.sequence.net.in;

import java.io.Serializable;

import android.content.Intent;

import com.zgcs.sequence.net.Package;
import com.zgcs.sequence.tool.ServiceTool;

public abstract class InPackage extends Package implements Serializable {

	public static final int RESULT_SUCESS = 1;
	private static final long serialVersionUID = 1L;
	protected String[] resultSpl;
	
	/**
	 * 初始化方法
	 * 
	 * @param result
	 *            指令
	 */
	public InPackage(String result) {
		parser(result);
	}

	/**
	 * 解析封装成对象
	 * 
	 * @param result
	 *            指令
	 */
	private void parser(String result) {
		if (result == null)
			return;
		resultSpl = result.split(ServiceTool.SPLIT);
		this.type = resultSpl[0];
		cmdID = Integer.parseInt(resultSpl[1]);
		parserSelf();
	}

	/**
	 * 解析封装成对象
	 * 
	 * @param result
	 *            指令
	 */
	public abstract void parserSelf();

	/**
	 * 获取广播传递数据
	 * 
	 * @return
	 */
	public Intent disposerOrder() {
		Intent intent = new Intent(this.type);
		intent.putExtra(this.type, this);
		return intent;
	}
}
